import { Component, OnInit } from '@angular/core';
import { AppPaginationComponent, PaginationModel } from "../../../../widgets/pagination/pagination.component";
import { OnetomanyCheckModalService } from './check.service';
@Component({
  selector: 'app-check',
  templateUrl: './check.component.html',
  styleUrls: ['./check.component.scss'],
  providers: [OnetomanyCheckModalService]
})
export class OnetomanyCheckModalComponent implements OnInit {
  //列表list数据
  public onetomanyCheckDetailList: any = [];
  //产品类型
  public sFundType:any; 
  //业务类型
  public sTypeName:any;
  // 列表是否全选
  public isCheckedAll = false;
  //一对一修改审核数据列表分页配置
  public onetomanyCheckListPageInfo: PaginationModel = {
    currentPageNum: 1,
    pageSize: 10,
    totalPages: 1,
    total: 0,
    pagesShow: 5,
    startRow: 0,
    endRow: 0,
    pageList: [5, 10, 25, 50, 100]
  };
  public onetomanyCheckDetailGetBody: any = {
    pageIndex: "1",
    pageSize: "10",
    sFundType: "2",
    nExaminNo: ""
  }
  constructor(
    private onetomanyCheckModalService: OnetomanyCheckModalService
  ) { }

  ngOnInit() {
    this.getCheckDetailList();
  }
  // 个数分页
  onetomanyCheckpageSizeChange(pageSize: number) {
    if (pageSize !== this.onetomanyCheckListPageInfo.pageSize) {
      this.onetomanyCheckListPageInfo.pageSize = pageSize;
      this.getCheckDetailList();
    }
  }
  // 页码分页
  onetomanyCheckPageNavigation(currentPageNum: number) {
    this.onetomanyCheckListPageInfo.currentPageNum = currentPageNum;
    this.getCheckDetailList(this.onetomanyCheckListPageInfo.currentPageNum, this.onetomanyCheckListPageInfo.pageSize);
  }
  //修改审核明细表数据查询
  getCheckDetailList(pageNum?, pageSize?) {
    let that = this;
    this.isCheckedAll = false;
    this.onetomanyCheckDetailGetBody.pageIndex = pageNum ? pageNum : this.onetomanyCheckListPageInfo.currentPageNum;
    this.onetomanyCheckDetailGetBody.pageSize = pageSize ? pageSize : this.onetomanyCheckListPageInfo.pageSize;
    this.onetomanyCheckModalService.getCheckDetailList(this.onetomanyCheckDetailGetBody).subscribe(data => {
      if (data) {
        that.onetomanyCheckDetailList = data.list;
        that.onetomanyCheckListPageInfo.currentPageNum = data.pageNum;
        that.onetomanyCheckListPageInfo.totalPages = data.pages;
        that.onetomanyCheckListPageInfo.total = data.total;
        that.onetomanyCheckListPageInfo.startRow = data.startRow;
        that.onetomanyCheckListPageInfo.endRow = data.endRow;
      }
    })
  }
}
